Repository Public
1/**2 * =============================================================================3 * SP BOUCHER | SOFTWARE & RESEARCH4 * ARTIFICIAL INTELLIGENCE • FINANCE • ENGINEERING5 * =============================================================================6 *7 * Project : Sheet8 * File : src/app/(site)/s/[slug]/opengraph-image.tsx9 * Module : app10 * Repository : https://git.spboucher.ai/sheet11 * Project Website : https://sheet.spboucher.ai12 * Created : 2026-11-1713 * Last Modified : 2026-11-1714 *15 * Author : Simon-Pierre Boucher16 * Position : Professor of Finance17 * Institution : Université du Québec en Outaouais (UQO)18 * Organization : SP Boucher19 * Website : https://spboucher.ai20 * Git : https://git.spboucher.ai21 *22 * Preferred Contact: contact@spboucher.ai23 * Development : dev@spboucher.ai24 * Support : support@spboucher.ai25 * Security/Admin : admin@spboucher.ai26 *27 * Copyright (c) 202628 * Simon-Pierre Boucher29 * All rights reserved where applicable. This file is governed by the30 * applicable project license, copyright notices and relevant law.31 * Existing third-party rights and notices remain unaffected.32 *33 * License : None specified (no license file in this repository)34 *35 * Do not embed credentials, private keys, access tokens,36 * certificates or confidential personal information.37 *38 * =============================================================================39 * END OF SP BOUCHER SOURCE HEADER40 * =============================================================================41 */4243import { ImageResponse } from "next/og";44import { env } from "@/lib/env";45import { plainMath } from "@/renderer/mathtext";46import { getPublished } from "@/server/sheets";4748export const dynamic = "force-dynamic";49export const alt = "Sheet — by Simon-Pierre Boucher";50export const size = { width: 1200, height: 630 };51export const contentType = "image/png";5253/** Sharing image generated from the published title and summary (used when no custom image is set). */54export default async function Image({ params }: { params: Promise<{ slug: string }> }) {55 const { slug } = await params;56 const r = /^[a-z0-9-]{1,96}$/.test(slug) ? await getPublished(slug, "fr") : null;57 const s = r && "sheet" in r ? r.sheet : null;58 const title = s?.title ?? "Sheet";59 const topics = s ? s.topics.slice(0, 3).map((t) => (s.locale === "en" ? t.name_en : t.name_fr)).join(" · ") : "";60 return new ImageResponse(61 (62 <div style={{ width: "100%", height: "100%", display: "flex", flexDirection: "column", justifyContent: "space-between", background: "#fbfaf7", color: "#0e1726", padding: 72, fontFamily: "sans-serif" }}>63 <div style={{ display: "flex", alignItems: "center", fontSize: 26, letterSpacing: 3, textTransform: "uppercase", color: "#2f4bff", fontWeight: 700 }}>{topics || "Sheet"}</div>64 <div style={{ display: "flex", flexDirection: "column" }}>65 <div style={{ display: "flex", fontSize: title.length > 70 ? 56 : 72, fontWeight: 700, lineHeight: 1.08, letterSpacing: -1.5 }}>{title}</div>66 {s?.summary ? <div style={{ display: "flex", marginTop: 26, fontSize: 30, lineHeight: 1.35, color: "#4b5567" }}>{((x: string) => (x.length > 170 ? x.slice(0, 168) + "…" : x))(plainMath(s.summary))}</div> : null}67 </div>68 <div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", borderTop: "2px solid #e4e0d6", paddingTop: 28, fontSize: 28 }}>69 <div style={{ display: "flex", alignItems: "center" }}>70 <div style={{ display: "flex", width: 52, height: 52, borderRadius: 13, background: "#0e1726", marginRight: 18, alignItems: "center", justifyContent: "center" }}>71 <div style={{ display: "flex", width: 22, height: 30, borderRadius: 3, background: "#fbfaf7" }} />72 </div>73 <div style={{ display: "flex", fontWeight: 700 }}>Sheet</div>74 <div style={{ display: "flex", marginLeft: 12, color: "#4b5567" }}>— by Simon-Pierre Boucher</div>75 </div>76 <div style={{ display: "flex", color: "#6f7889" }}>{new URL(env.appUrl).host}</div>77 </div>78 </div>79 ),80 size,81 );82}83